/*
 * Java Futbol Bruno
 */

package futbol.tacticas.concursantes2007.JFBRUNO;

import futbol.tacticas.*;
import futbol.tacticas.concursantes.Tactica;

import java.awt.Color;
import java.awt.Point;
import java.util.Vector;

/**
 * @author Bruno Ponsanesi
 */
public class TacticaJFBruno implements Tactica{
    
    private int nValores[][]={
            {-150,0,7},//1[0]
            {-88,50,5},//2[1]
            {-88,-50,5},//3[2]
            {-130,-10,4},//4 [3] -120,-20     
            {-100,10,4},//5[4]
            {72,76,7},//6[5]
            {-20,30,5},//7[6]
            {-20,-30,5},//8[7]
            {90,45,6},//9[8]
            {90,-45,6},//10[9]
            {72,-76,7}//11[10]50,-80  64,-60
    };

    public String getNombre(){
        return "JF BRUNO";
    }
    
    public Color getColor1(){
        return Color.black;
    }
    
    public Color getColor2(){
        return Color.black;
    }
    
    public Color getColorNumero(){
        return Color.white;
    }
    
    public int getFuerza(int n){
        return nValores[n][2];
    }
    public int getXInicial(int n){
        return nValores[n][0];
    }
    
    public int getYInicial(int n){
        return nValores[n][1];
    }
    
    public Vector<Comando> getComandos(SituacionJugadores b) {
        Vector<Comando> com=new Vector();
        
        //posision
        for (int n=0;n<11;n++)
            com.add(new ComandoIrA(n,nValores[n][0],nValores[n][1]));

        Point bola=b.getBola();
        Point jugadores[]=b.getMisJugadores();
        Point contrarios[]=b.getContrario();
        
        //cerca a la pelota
        int jB=b.getMasCercanoDeBola();
        com.add(new ComandoIrA(jB,bola.getX(), bola.getY()));
        
        //arquero
        int y=(int)(bola.getY()/2);
        if (y<-20) y=-20;
        if (y>20) y=20;
        if(y>0) y+=2;
        if(y<0) y-=2;
        com.add(new ComandoIrA(0,nValores[0][0], y));
        
        //defensa
        if (!b.estoyMasCercaDeBola() || bola.getX()<0){
            for (int n=1;n<3;n++){
                int nJC=b.getContrarioMasCerca(getXInicial(n), getYInicial(n));
                double xx;
                double yy;
                double xb = bola.getX();
                double yb = bola.getY();
                double xj = contrarios[nJC].getX();
                double yj = contrarios[nJC].getY();
                if(xj>xb){
                	xx=xj-12;
                }else{
                	xx=xj+12;
                }
                if(yj>yb){
                	yy=yj-12;
                }else{
                	yy=yj+12;
                }
                com.add(new ComandoIrA(n, xx, yy));
            }
        }

        //patear
        for (int n=0;n<11;n++){
        	if(n==6){
        		com.add(new ComandoPase(6,5));	
        	}else if(n==7){
        		com.add(new ComandoPase(7,10));	
        	}else if(n==1||n==0){
        		com.add(new ComandoPase(n,6));	
        	}else if(n==2){
        		com.add(new ComandoPase(n,7));	
        	}else if(n==3){
        		com.add(new ComandoPase(n,7));	
        	}else if(n==4){
        		com.add(new ComandoPase(n,6));	
        	}else{
        	   com.add(new ComandoTiroAPuerta(n,0));
        	}
            
        }
        
        return com;
    }
    
}